<template>
  <div class="photo-list">
    <van-tabs animated>
      <van-tab
        v-for="cate in cates"
        :key="cate.id"
      >
        <template #title>
          <div @click="getImages(cate.id)">
            {{cate.title}}
          </div>
        </template>
        <ul
          class="img-box"
          v-if="images.length > 0"
        >
          <li
            class="img-item"
            v-for="image in images"
            :key="image.id"
            @click="goDetail('/home/photoinfo',image.id)"
          >
            <img
              v-lazy="image.img_url"
              alt=""
            >
          </li>
        </ul>
        <div v-else>
          暂无数据
        </div>
      </van-tab>
    </van-tabs>

  </div>
</template>
<script>
// import mixins from '@/mixins'
export default {
  // mixins: [mixins],
  data() {
    return {
      cates: [],
      images: []
    }
  },
  created() {
    this.getImageCategory()
    this.getImages(0)
  },
  methods: {
    async getImageCategory() {
      const res = await this.$http.getImageCategory()
      res.data.message.unshift({
        id: 0,
        title: '全部'
      })
      this.cates = res.data.message
    },
    async getImages(id) {
      const res = await this.$http.getImages(id)
      this.images = res.data.message
    }
  }
}
</script>
<style lang="scss" scoped>
.photo-list {
  padding: 0 10px 10px 10px;
  img {
    width: 100%;
    height: 100%;
    display: block;
  }
}
</style>